package com.hc.bean;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component //将类交给Spring管理,（value=""）可指定默认的id,默认根据类名的第二个字母是否大小写来改变第一个字母大小写作为id的值
@Scope("singleton") //控制是否单例
@Lazy(value = false) //控制是否懒加载
public class User {
    @Value("${name}") //简单类型${xxx}
    private String name;
    @Value("#{@customValue}") //复杂类型#{@xxx}
    private Integer[] age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer[] getAge() {
        return age;
    }

    public void setAge(Integer[] age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + Arrays.toString(age) +
                '}';
    }
}
